<template>
	<view class="pics">
		<scroll-view scroll-y="true" class="left">
			<view 
			:class="index===active? 'active':''" 
			v-for="(i,index) in category" 
			:key=i.id
			@click="change(index,i.id)">
			{{i.title}}
			</view>
		</scroll-view>
		<scroll-view scroll-y="true" class="right">
			<view class="item">
				<image :src="detail[active].img_url" mode=""></image>
				<text>{{detail[active].title}}</text>
			</view>
		</scroll-view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				category:[],
				active:0,
				id:0,
				detail:[]
			}
		},
		onLoad(){
			this.getCategory(),
			this.getimg()
		},
		methods: {
			 async getCategory(){
				let res = await this.$myRequest({
					url:"/api/getimgcategory"
				})
				this.category=res.data.message
				this.id=this.category[0].id
			},
			change(index,id){
				this.active=index
				this.id=id
			},
			async getimg(){
				let res = await this.$myRequest({
					url:"/api/getimages/"+this.id
				})
				this.detail=res.data.message
			}
		}
	}
</script>

<style lang="scss">
	page{
		height: 100%;		
	}
	.pics{
		height: 100%;
		display: flex;
		.left{
			
			width: 200rpx;
			height: 100%;
			border-right: 1px solid #eee;
			view{
				height: 60px;
				line-height: 60px;
				color: #333;
				text-align: center;
				font-size: 30rpx;
				border-top: 1px solid #eee;	
			}
			.active{
				background: $index_color;
				color: #fff;
			}
		}
		.right{
			width: 520rpx;
			height: 100%;
			margin: 10rpx auto;
			.item{
				image{
					width:520rpx;
					height: 520rpx;
					border-radius: 5px;
				}
				text{
					font-size: 30rpx;
					line-height: 60rpx;
				}
			}
		}
	}

</style>
